package com.lancoo.znbkxx.teacher.aibkTestCoach.aibkDialog

import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerViewHolder
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.PaperEvaluationInfor
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CompoundButton
import androidx.appcompat.app.AppCompatActivity
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerAdapter
import com.lancoo.znbkxx.teacher.R
import kotlinx.android.synthetic.main.aibk_adapter_item_evaluation_point.view.*

class AdapterEvluationEvport(
        val activity:AppCompatActivity,
        val paperEvaluationInfor: PaperEvaluationInfor,
        val listTags: MutableList<String>
) : KBaseRecyclerAdapter(){

    override fun getHolderView(parent: ViewGroup?, position: Int): View? {
        return LayoutInflater.from(activity)
                .inflate(R.layout.aibk_adapter_item_evaluation_point, parent, false)
    }

    override fun onBindViewHolder(holder: KBaseRecyclerViewHolder, position: Int) {
        holder.convertView.TvObject.text = listTags[position].toString()

        holder.convertView.ChechBoxObject.isChecked = true
        holder.convertView.ChechBoxObject.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener
        { buttonView, isChecked ->
            if(listTags[position] == "试题解析") {
                paperEvaluationInfor.CommentExportTags.AnswerAnalysis = isChecked
            }else if(listTags[position] == "听力原文"){
                paperEvaluationInfor.CommentExportTags.ListenText = isChecked
            }else if(listTags[position] == "听力音频"){
                paperEvaluationInfor.CommentExportTags.ListenVideo = isChecked
            }else if(listTags[position] == "试题知识点"){
                paperEvaluationInfor.CommentExportTags.Zsd = isChecked
            }
            holder.convertView.ChechBoxObject.isChecked = isChecked
        })
    }

    override fun getItemCount(): Int {
        return listTags.size
    }

    override fun getItemViewType(position: Int): Int {
        return position
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }
}